package com.niit.mall.common.config;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.math.BigInteger;

/**
 * @BelongsProject: pardo_mall_backend
 * @BelongsPackage: com.niit.mall.common.config
 * @Author: ChuXuan
 * @CreateTime: 2025-06-09  09:11
 * @Description: TODO
 * @Version: 1.0
 */

@Configuration
@ConditionalOnClass(ObjectMapper.class)
public class JsonConfig {
	@Bean
	public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
		return jacksonObjectMapperBuilder -> {
			// long -> string
			jacksonObjectMapperBuilder.serializerByType(Long.class, ToStringSerializer.instance);
			jacksonObjectMapperBuilder.serializerByType(BigInteger.class, ToStringSerializer.instance);
		};
	}
}